<!DOCTYPE html>
<html>
   <head>
        <title>后台管理</title>
        <meta charset="utf-8">
        <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <!-- 引入资源文件 -->
        <#include "../../common/res.html" />
   </head>
   
   <body class=""> 
  	<!-- top 导航 -->
    <#include "../../common/header.html" />
	
	<!-- 菜单导航 -->
    <#include "../cms-nav.html" />
    
    <div class="content">
        <div class="container-fluid">
			
			<form id="queryPageForm" class="mt-15" >
				<div class="block span6">
					<a class="block-heading f-14" data-toggle="collapse">教师管理</a>
					<div class="block-body collapse in">
						<p>
							<select  name="status" class="search-select">
								<option value="-1">全部</option>
								<option value="2" <#if (queryEntity.status)?? && queryEntity.status ==2>selected="selected"</#if> >可用</option>
								<option value="0" <#if (queryEntity.status)?? && queryEntity.status ==0>selected="selected"</#if>>禁用</option>
							</select>
						</p>
						<p>
							<input name="username" type="text" value="${(queryEntity.username)!}" class="search-text" placeholder="请输入登录名" />
						</p>
						<p>
							<input type="submit" class="search-btn" value="搜索" />
						</p>
					</div>
				</div>

				<div class="row-fluid">
					<div class="block span6">
						<div id="tablewidget" class="block-body collapse in">
							<table class="table">
								<thead>
									<tr>
										<th>姓名</th>
										<th>登录名</th>
										<th>学历</th>
										<th>学校</th>
										<th>手机</th>
										<th>状态</th>
										<th>性别</th>
										<th>权重</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									<#if (page.items)??>
									<#list page.items as item>
									<tr>
										<td>${item.realname!}</td>
										<td>${item.username!}</td>
										<td>${item.education!}</td>
										<td>${item.collegeName!}</td>
										<td>${item.mobile!}</td>
										<td>
											<#if item.status == 2>
											可用
											<#elseif item.status == 0>
											禁用
											<#else>
											未知
											</#if>
										</td>
										<td>
											<#if item.gender == 0>
											女
											<#else>
											男
											</#if>
										</td>
										<td>${item.weight!}</td>
										<td>
											<a href="javascript:void(0)" onclick="toEdit(${item.id});">修改</a>
										</td>
									</tr>
									</#list>
									</#if>
								</tbody>
							</table>
							<p><#include "../../common/tailPage.html"/></p>
						</div>
					</div>
				</div>
			</form>
			
    	</div>
	</div>

	<!-- 弹出层 -start -->
	<div class="modal fade " id="myModal" tabindex="-1" role="dialog"  aria-hidden="true">
		<div class="modal_wapper">
			<div class="modal-dialog " >
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
							<span aria-hidden="true">×</span>
						</button>
						<h4 class="modal-title" >修改教师信息</h4>
					</div>
					
					<div class="modal-body">
						<form id="myForm" role="form" id="ff" action="${s.base}/user/doMerge.html">
							<input type="hidden"  name="id" />
							<div class="form-group">
								<label for="name">名称</label> 
								<input type="text" class="form-control"  readonly="readonly" name="realname" placeholder="请输入名称">
							</div>
							<div class="form-group">
								<label for="name">登录名</label> 
								<input type="text" class="form-control" readonly="readonly"  name="username"  placeholder="请输入名称">
							</div>
							<div class="form-group">
								<label for="name">状态</label> 
								<select id="status" name="status" class="form-control"  type="select">
									<option value="2">可用</option>
									<option value="0">禁用</option>
								</select>
							</div>
						</form>
					</div>
					
					<div class="modal-footer">
						<button type="button" class="btn btn-default" onclick="doSave();">保存</button>
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- 弹出层 -end -->
	
	<script type="text/javascript">
		function toEdit(id){
			$.ajax({
				url:'${s.base}/user/getById.html',
			    type:'POST',
			    dataType:'json',
			    data:{"id":id},
			    success:function(resp){
			    	var errcode = resp.errcode;
			    	if(errcode == 0){
			    		$("#myForm").fill(resp.data);
			    		$('#myModal').modal('show');
			    	}
			    } 
			});
		}
		
		function doSave(){
			$('#myForm').ajaxSubmit({
				datatype : 'json',
				success : function(resp) {
					var resp = $.parseJSON(resp);
					if (resp.errcode == 0) {
						$('#myModal').modal('hide');
						_queryPage();
					} else {
						Modal.tipFailure(resp.message);//失败提示 
					}
				},
				error: function(){
					Modal.tipFailure('保存失败');
                    //alert(arguments[0].responseText);
                }
			});	
		}
		
		
	</script>
	
</body>
</html>
